<template>
	<view>
		<view>
			<u-cell-group>
				<u-cell size="large" title="照片">
					<image slot="value" :src="trainer.avatar" style="width: 100px;" mode="widthFix"></image>
				</u-cell>
				<u-cell size="large" title="姓名" :value="trainer.trName"></u-cell>
				<u-cell size="large" title="年龄" :value="trainer.age"></u-cell>
				<u-cell size="large" title="性别">
					<text slot="value">{{trainer.gender === 1 ? '男':'女'}}</text>
				</u-cell>
				<u-cell size="large" title="从业时间" :value="trainer.career"></u-cell>

				<u-cell size="large" title="入职时间" :value="trainer.joinTime"></u-cell>
				<u-cell size="large" title="擅长方向" :value="trainer.expertiseNames">
				</u-cell>
				<u-cell size="large" title="简介" :value="trainer.intro"></u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				trainer: {},
			};
		},
		onLoad(options) {
			this.getById(options.id)
		},
		methods: {
			async getById(id) {
				let {
					data: res
				} = await uni.$http.get('/user/trainer/' + id)
				if (res.code === 20000) {
					this.trainer = res.data
					this.trainer.expertiseNames = this.getExpertiseList(this.trainer.expertiseList)
				} else {
					uni.$showMsg(res.msg)
				}

			},
			getExpertiseList(expertiseList) {
				let expertiseNames = []
				if (Array.isArray(expertiseList)) {
					for (let i = 0; i < expertiseList.length; i++) {
						expertiseNames.push(expertiseList[i].categoryName)
					}
					return expertiseNames.toString()
				}
				return
			}
		}

	}
</script>

<style lang="scss">

</style>